/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * PlaylistCellWithArtPanel.java
 *
 * Created on Mar 8, 2009, 2:36:51 PM
 */
package com.bff.mpd.musicjukebox.ui.components;

import com.bff.bjj.ui.component.BJJPanel;
import com.bff.mpd.musicjukebox.lib.ColorProperties;
import com.bff.mpd.musicjukebox.lib.JukeboxProperties;
import java.awt.Color;
import org.bff.javampd.MPDPlaylist;

/**
 *
 * @author Music
 */
public class YearCellPanel extends javax.swing.JPanel {

    private MPDPlaylist playlist;
    private String year;

    /** Creates new form PlaylistCellWithArtPanel */
    public YearCellPanel(String year) {
        setYear(year);

        this.playlist = JukeboxProperties.getInstance().getPlaylist();

        initComponents();

        try {
            lblYear.setText(year);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        detailPanel = new javax.swing.JPanel();
        lblYear = new javax.swing.JLabel();
        jPanel1 = new BJJPanel();
        btnAdd = new YearAddButton(getPlaylist(), getYear());
        btnAdd.setText(null);

        setLayout(new java.awt.BorderLayout());

        lblYear.setText("jLabel1");
        detailPanel.add(lblYear);

        add(detailPanel, java.awt.BorderLayout.WEST);

        jPanel1.setLayout(new java.awt.GridBagLayout());

        btnAdd.setIcon(new javax.swing.ImageIcon(getClass().getResource("/resources/mpd/add.png"))); // NOI18N
        btnAdd.setContentAreaFilled(false);
        jPanel1.add(btnAdd, new java.awt.GridBagConstraints());

        add(jPanel1, java.awt.BorderLayout.EAST);
    }// </editor-fold>//GEN-END:initComponents
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnAdd;
    private javax.swing.JPanel detailPanel;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JLabel lblYear;
    // End of variables declaration//GEN-END:variables

    public void setEven() {
        setBackground(ColorProperties.LIST_BACKGROUND_EVEN);
    }

    public void setOdd() {
        setBackground(ColorProperties.LIST_BACKGROUND_ODD);
    }

    public void setCurrentPlaying() {
        setForeground(ColorProperties.PLAYLIST_CURRENT_PLAYING_FOREGROUND);
    }

    public void setSelected() {
        setForeground(ColorProperties.LIST_FOREGROUND_SELECTED);
        setBackground(ColorProperties.LIST_BACKGROUND_SELECTED);
        showAddButton();
    }

    public void setNotSelected() {
        setForeground(ColorProperties.LIST_FOREGROUND);
        hideAddButton();
    }

    @Override
    public void setBackground(Color bg) {
        super.setBackground(bg);
        //detailPanel.setBackground(bg);
        if (detailPanel != null) {
            detailPanel.setBackground(bg);
            jPanel1.setBackground(bg);
        }
    }

    @Override
    public void setForeground(Color fg) {
        super.setForeground(fg);
        if (detailPanel != null) {
            detailPanel.setForeground(fg);
            jPanel1.setForeground(fg);
        }
        setLabelColors(fg);
    }

    private void setLabelColors(Color color) {
        if (lblYear != null) {
            lblYear.setForeground(color);
        }
    }

    public void setAddButtonVisible(boolean visible) {
        jPanel1.setVisible(visible);
    }

    public void showAddButton() {
        setAddButtonVisible(true);
    }

    public void hideAddButton() {
        setAddButtonVisible(false);
    }

    public MPDPlaylist getPlaylist() {
        return playlist;
    }

    public void setPlaylist(MPDPlaylist playlist) {
        this.playlist = playlist;
    }

    public void setCurrent() {
        setLabelColors(ColorProperties.PLAYLIST_CURRENT_PLAYING_FOREGROUND);
    }

    public void setNotCurrent() {
        setLabelColors(ColorProperties.LIST_FOREGROUND_SELECTED);
    }

    /**
     * @return the year
     */
    private String getYear() {
        return year;
    }

    /**
     * @param year the year to set
     */
    private void setYear(String year) {
        this.year = year;
    }
}
